1 module hip.api.console;
2 
3 version(PSVita) version = ErrorOnLoadSymbol;
4 version(WebAssembly) version = ErrorOnLoadSymbol;
5 
6 version(DirectCall)
7 {
8 	import hip.console.log;
9 	///Only the scripting API will need to have this mixed.
10 	version(Have_hipreme_engine){}else
11 	{
12 		mixin mxGenLogDefs!();
13 	}
14     alias log = rawlog;
15 	alias logg = logln;
16 }
17 else version(ScriptAPI)
18 {
19 	alias logFn = extern(System) void function(string);
20     __gshared logFn log = null;
21 	void initConsole()
22 	{
23 		version(ErrorOnLoadSymbol)
24 		{
25 			assert(false, "Cannot load symbols in this version.");
26 		}
27 		else
28 		{
29 			import hip.api.internal : _loadSymbol, _dll;
30 			log = cast(typeof(log))_loadSymbol(_dll, "log".ptr);
31 			log("HipengineAPI: Initialized Console");
32 		}
33 	}
34     void logg(Args...)(Args a, string file = __FILE__, size_t line = __LINE__)
35 	{
36 		import hip.util.conv;
37 		string toLog;
38 		foreach(arg; a)
39 			toLog~= arg.to!string;
40 		log(toLog ~ "\n\t at "~file~":"~to!string(line));
41 	}
42 }
43 
44 void logVars(Args...)(string file = __FILE__, size_t line = __LINE__)
45 {
46 	import hip.util.conv;
47 	string toPrint;
48 	bool isFirst = true;
49 	static foreach(i; 0..Args.length)
50 	{
51 		if(!isFirst)
52 			toPrint~=", ";
53 		toPrint~= __traits(identifier, Args[i])~": "~Args[i].to!string;
54 		isFirst = false;
55 	}
56 	version(DirectCall)
57 	{
58 		import hip.console.log:rawlog;
59 		rawlog(toPrint ~ "\n\t at "~file~":"~to!string(line));
60 	}
61 	else version(ScriptAPI)
62 		log(toPrint ~ "\n\t at "~file~":"~to!string(line));
63 }